home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.0 KB | 107 lines | [TEXT/GEOL] |
- Item 3724833 29-Aug-90 01:59PDT
-
- From: AUST0338 AUPtnr - Tactics Int'l,Shillito,IDV
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: CopyMask while printing
-
- To: MACAPP.TECH$
- From: AUST0338 - David Shillito
- Date: 29th August 1990
-
- Subject: CopyMask while printing
-
- In our application there is a need to display icons in views which are
- printable. Everything was working OK with the icons being displayed on the
- screen but when the time came to print - nothing came out. We were using
- CopyMask to display the icon but when I had another look at IM Page V-71 I saw
- the words "CopyMask doesnt send any of its drawing commands through grafProc
- routines; thus CopyMask calls are not recorded in pictures". After some thought
- I came up with the following code which seems to work OK but I can only test on
- the ImageWrtiter and HP PaintJet drivers. Does anyone know of any reason why
- this code might break on other devices such as the LaserWriter or the various
- color Postscript devices?
-
- David Shillito
-
- PROCEDURE PlotFMIcon (r: Rect; theIcon: FMIcon);
- VAR
- iconRect: Rect;
- iconMap ,
- maskMap ,
- dstMaskMap : BitMap;
- dstMaskRgn : RgnHandle;
- dstMaskBits : Ptr;
- dstRowBytes : LONGINT;
- BEGIN
- SetRect (iconRect, 0, 0, 32, 32);
- WITH iconMap DO
- BEGIN
- baseAddr:= @theIcon.iconBits;
- rowBytes:= 4;
- bounds := iconRect;
- END;
- WITH maskMap DO
- BEGIN
- baseAddr:= @theIcon.maskBits;
- rowBytes:= 4;
- bounds := iconRect;
- END;
-
- IF gPrinting THEN
- BEGIN
- dstRowBytes := (((r.right - r.left - 1) DIV 16) + 1) * 2;
- dstMaskRgn := NewRgn;
- dstMaskBits := NewPtr (LONGINT(r.bottom-r.top)*dstRowBytes);
- IF (dstMaskRgn <> NIL) | (dstMaskBits <> NIL) THEN
- BEGIN
- { scale the mask bit map to the size of the destination rectangle }
- WITH dstMaskMap DO
- BEGIN
- baseAddr:= dstMaskBits;
- rowBytes:= dstRowBytes;
- bounds := r;
- END;
- RGBForeColor (gRGBBlack); { reset}
- RGBBackColor (gRGBWhite);
- CopyBits (maskMap, dstMaskMap, iconRect, r, srcCopy, NIL);
- { convert the new mask to a region }
- IF BitMapToRegion (dstMaskRgn, dstMaskMap) = noErr THEN
- BEGIN
- { use the region to restrict the copy into the grafport }
- RGBForeColor (theIcon.foreColor);
- RGBBackColor (theIcon.BackColor);
- CopyBits (iconMap, thePort^.portBits, iconRect , r, srcCopy, dstMaskRgn);
- END;
- END;
- IF dstMaskRgn <> NIL THEN
- DisposeRgn (dstMaskRgn);
- IF dstMaskBits <> NIL THEN
- DisposPtr (dstMaskBits);
- END
- ELSE
- BEGIN
- RGBForeColor (theIcon.foreColor);
- RGBBackColor (theIcon.BackColor);
- CopyMask ( iconMap , maskMap , thePort^.portBits,
- iconRect, iconRect , r);
- END;
- RGBForeColor (gRGBBlack); { reset}
- RGBBackColor (gRGBWhite);
- END {PlotFMIcon};
-
- where
-
- FMIconBitsArray = ARRAY [0..31] OF LONGINT;
- FMIcon = RECORD
- iconBits,
- maskBits: FMIconBitsArray;
- foreColor ,
- backColor : RGBColor;
- END {FMIcon};
-
-
-
-
-